package com.example.firstdemo.ui.screens.pages.mine

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.firstdemo.network.service.UserManager
import com.example.firstdemo.ui.screens.pages.mine.data.MinePageUIState
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch

class MineViewModel : ViewModel() {
    private var _uiState = MutableStateFlow(MinePageUIState())
    val uiState: StateFlow<MinePageUIState> = _uiState

    init {
        viewModelScope.launch {
            UserManager.currentUser.collect { state ->
                uiState.value.userInfo = state
            }
        }
    }

    fun setShowDialog(show: Boolean) {
        _uiState.value = _uiState.value.copy(showDialog = show)
    }
}